package com.example.origin.aspect.controller;

import lombok.Data;
import org.springframework.web.bind.annotation.*;

/**
 * @author yutao.zhang
 * @create 2023-07-25 16:27
 **/
@RestController
public class DemoController {

    @GetMapping("demo")
    public String demo(@RequestParam String msg) {
        return msg;
    }

    @GetMapping("error")
    public String error(@RequestParam(required = false, defaultValue = "0") Integer flag) {
        if (flag == 1) {
            int i = 1 / 0;
        }
        return "";
    }


    @PostMapping("postdemo")
    public Demo postdemo(@RequestParam(required = false, defaultValue = "0") Integer flag, @RequestBody Demo demo) {
        return demo;
    }

    @Data
    private static class Demo {
        private String name;
        private Integer age;
    }


}
